package com.albaba.designpattern.visitor.text_001;

import java.time.LocalDate;

/**
 * @Description: 水果类
 * @Author zx
 * @Date 2025/2/25 18:16
 * @Version 1.0
 */
public class Fruit extends Product implements Acceptable{

    // 重量
    private double weight;

    public Fruit(String name, LocalDate produceDate, double price, double weight) {
        super(name, produceDate, price);
        this.weight = weight;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }

    @Override
    public void accept(Visitor visitor) {
        // 在accept方法中调用访问者，并将自己 this 传递回去
        visitor.visit(this);
    }
}
